#
# @lc app=leetcode.cn id=66 lang=python3
#
# [66] 加一
#

# @lc code=start
class Solution:
    def plusOne(self, digits: List[int]) -> List[int]:
        c = 1
        i = -1
        while c == 1 :
            if i + len(digits) >= 0:
                if digits[i] == 9:
                    digits[i] = 0
                    i -= 1
                else:
                    c = 0
                    digits[i] += 1
            else:
                digits = [1] + digits
                c= 0
        return digits
# @lc code=end

